from datetime import datetime
from typing import Optional, List, ForwardRef
from pydantic import BaseModel

from .question import QuestionInDB

class QuestionSetBase(BaseModel):
    title: str
    description: Optional[str] = None

class QuestionSetCreate(QuestionSetBase):
    pass

class QuestionSetUpdate(QuestionSetBase):
    pass

class QuestionSetInDBBase(QuestionSetBase):
    id: int
    created_at: datetime
    updated_at: datetime

    class Config:
        from_attributes = True

class QuestionSet(QuestionSetInDBBase):
    pass

class QuestionSetWithQuestions(QuestionSet):
    questions: List[QuestionInDB] = []

class QuestionSetQuestionBase(BaseModel):
    question_set_id: int
    question_id: int
    sort_order: Optional[int] = 0

class QuestionSetQuestionCreate(QuestionSetQuestionBase):
    pass

class QuestionSetQuestionUpdate(QuestionSetQuestionBase):
    pass

class QuestionSetQuestionInDBBase(QuestionSetQuestionBase):
    id: int

    class Config:
        from_attributes = True

class QuestionSetQuestion(QuestionSetQuestionInDBBase):
    pass 